class_name MapSystem
extends BaseSystem

@export_group("Room参数")
@export var rooms_by_type:Array[RoomListByType]
@export_group("")
@export_group("Map参数")
@export_group("")
@export_group("MiniMap参数")
@export_group("")
var cur_room_id:int:
	get:
		return -1 if not cur_room else cur_room.room_id
var cur_room:BaseRoom
var _rooms_dict:Dictionary = {}

func generate_map() -> BaseRoom:
	var room_type = Util.random_get_count(GameEnum.RoomType.keys(),1,false)
	if not rooms_by_type.has(room_type):
		return generate_map()
	var room_list = rooms_by_type[room_type]
	if room_list.size() <= 0:
		return generate_map()
	cur_room = Util.random_get_count(room_list,1,false)
	return cur_room
func generate_map_by_type(room_type:GameEnum.RoomType) -> BaseRoom:
	if _rooms_dict.has(room_type):
		cur_room = Util.random_get_count(_rooms_dict[room_type],1,false).instantiate()
		add_child(cur_room)
		cur_room.init_room()
	return cur_room
func init_system():
	super.init_system()
	_rooms_dict = {}
	for rooms in rooms_by_type:
		_rooms_dict[rooms.room_type] = rooms.room_scenes
